/*
 * InvalidRecordException.java
 *
 * Created on December 13, 2005, 3:57 PM
 *
 */
package biofilter.exceptions;

import java.io.IOException;

/**
 * Supporting class - used to indicate an Invalid Record was passed to a method.
 * @author  yan, rox, tom
 */
public class InvalidRecordException extends IOException {
    //Add this to avoid warning: [serial] serializable class 
    //core.util.logic.InvalidRecordException has no definition of serialVersionUID.
    private static final long serialVersionUID = 7526471155622776147L;
    protected boolean fatal = false;
	protected String ireMessage;

    /** Creates a new instance of InvalidRecordException. */
    public InvalidRecordException( ) {
        this(null);
    }

    /** 
     * Creates a new instance of InvalidRecordException. 
     * @param message A custom message that you want included in the error.
     */
    public InvalidRecordException( String message) {
        this(message, false);
    }
    
    /** 
     * Creates a new instance of InvalidRecordException.
     * @param message A custom message that you want included in the error.
     * @param fatal This is a boolean, true if you want the exception to be
     * fatal and false if you don't want the exception to be fatal.
     */
    public InvalidRecordException( String message, boolean fatal) {
        super( message);
        this.fatal = fatal;
		this.ireMessage = message;
    }
    
    /**
     * Returns value of fatal
     * @return boolean - fatal
     */
    public boolean isFatal() {
        return fatal;
    }
    
    /**
     * Returns the message of the exception with the String Fatal Exception prepended to it.
     * @return String - exception message
     */
    public String getMessage() {
        String message;
         if(fatal) {
             message = "Fatal Exception: " + super.getMessage();
         }
         else {
             message = "Exception: " + super.getMessage();
         }
         return message;        
    }        
}
